package com.xm.web.controller.config;

import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
 * @author yousj
 * @since 2022-03-23
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/config")
@RefreshScope
@Api(tags = "配置中心")
@Slf4j
public class ConfigController {

    @Value("${nacos.config.test:hello}")
    private String nacosConfigTest;

    @GetMapping("/get")
    public String get() {
        return nacosConfigTest;
    }

    @GetMapping("/error")
    public void error() {
        log.error("错误啦: ", new RuntimeException(UUID.randomUUID().toString()));
    }

}
